{% for year, date_year in dates|groupby('date.year')|sort(reverse=True) %}
    <h2>
        {% if YEAR_ARCHIVE_SAVE_AS %}
            <a href="{{ SITEURL }}/{{ YEAR_ARCHIVE_SAVE_AS.format(date=date_year[0].date)|replace('index.html', '') }}"
               rel="bookmark" title="Archives for {{ year }}"
               itemprop="url">
                {{ year }}
            </a>
        {% else %}
            {{ year }}
        {% endif %}
    </h2>
    {% include 'partials/archive_month.html' %}
{% endfor %}
